#ifndef TCP_SERVER_H
#define TCP_SERVER_H

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <unistd.h>
#include "config_protocol.h"
using namespace std;

#define MAXPACKETSIZE 4096

typedef enum CameraId
{
    CH_BACK_R = 0,   //右后视
    CH_BACK_W,       //后向微光
    CH_FRONT_DAL,     //前双目
    CH_BACK_DAL,      //后双目
    CH_FRONT_W,      //前向微光
    CH_FRONT_L,      //左前视
    CH_BACK_L,    //左后视
    CH_FRONT_R,    //右前视
    CH_STITCH,
    CH_MAX,
}UVC_CH;
class TCPServer
{
    public:
        int m_sockfd, m_newsockfd, n, pid;
        struct sockaddr_in serverAddress;
        struct sockaddr_in clientAddress;
        pthread_t serverThread;

        void setup(int port);
        void receive();
        static void data_analyse(Message recvMsg);

    private:
        static void * Task(void * argv);
        static uint8_t getXor(uint8_t* data, int length);
};
#endif
